import React from "react";
import Bus from "./Bus.js";
import A1 from "./A1";
class App extends React.Component {
  //PureComponent默认优化了组件更新,对比了更新时最新的props和就得props值,如果两次一样,则组件不更新
  constructor(props) {
    super(props);
    this.state ={
        theme: "red"
    }
    //1.创建上下文
  }
  //修改主题
  setTheme = (theme) => {
    this.setState({
        theme
    })
  };
  render() {
    return (
      <div>
        <Bus.Provider value={{ ...this.state, setTheme: this.setTheme }}>
          <A1></A1>
        </Bus.Provider>
      </div>
    );
  }
}

export default App;
